<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
    <head>
        <title>AdminiListListUsers</title>
        <meta charset="UTF-8">
       <base th:href="@{/}">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
                <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.0/dist/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
        
    </head>
     <script src="js/jquery-3.4.1.min.js"></script>
<body>
<table class="table table-hover table-striped">
            <h2>用户列表管理</h2>
            <hr>     

                     <tr>
                	<th>用户名</th>
                    <th>用户编号</th>
                    <th>电话</th>
                    <th>邮箱</th>
                    <th>账户余额</th>
                    <th>操作</th>
                    	
                </tr>
                    <tr th:each="c:${users}" th:id="|tr${c.Uid}|">
                    	<td th:text="${c.Uname}"></td>
                        <td th:text="${c.Uid}"></td>
                        <td th:text="${c.Ucall}"></td>
                        <td th:text="${c.Uemall}"></td>
                        <td th:text="${c.Uaccount}"></td>
                        <td>
                        <a th:href="|javascript:banuser('${c.Uid}');|">禁用</a>
                        <a th:href="|javascript:deleteuser('${c.Uid}');|">删除</a>
                              <a th:href="'editUser/'+${c.Uid}">编辑用户</a>
                       
                        </td>
                        </tr>
            </table>
            <br>
            <a class="btn btn-outline-danger" th:href="@{Administrators/AdminListBanUsers}">查看被禁用用户列表</a>&nbsp;<br><br>
             <a class="btn btn-outline-danger" th:href="@{'Adminindex/'+${session.session.Aid}}">返回首页</a>&nbsp;
          
</body>
<script>  //定义一个函数,根据学号删除学生
                function deleteuser(uid) {
                    $.ajax({
                        url: 'Administrators/deleteuser',
                        type: 'POST',
                        data: {Uid:uid}, //发送一个请求参数，参数名为stuId，参数值为传入的stuId变量的值
                        success: function () {
                        	 alert("删除成功！");
                        	  $("#tr" +uid).remove(); 
                        },
                        error: function (req, status, error) {
                            alert("删除失败！" + error);
                        }
                    });
                }
                function banuser(uid) {
                    $.ajax({
                        url: 'Administrators/banuser',
                        type: 'POST',
                        data: {Uid:uid}, //发送一个请求参数，参数名为stuId，参数值为传入的stuId变量的值
                        success: function () {
                        	  $("#tr" +uid).remove(); 
                        	  alert("禁用成功！");
                        },
                        error: function (req, status, error) {
                            alert("禁用失败！" + error);
                        }
                    });
                }
            </script>
        </div>
</html>